/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hr.cmi.android.aanwezigheidsregistratie.helper;

import java.util.HashMap;
import java.util.List;

/**
 *
 * @author Johan
 */
public class WebserviceWrapper {
    // Aanroepen van webservice

    // TODO foutafhandeling met try-catch block

    public static String[] getDocenten() {
        WebserviceHelper wsHelper = new WebserviceHelper();
        List<String> lijst = wsHelper.callWebservice(WebserviceHelper.GET_DOCENTEN);
        String docentensep = lijst.get(0); // Hele rij komma-separated
        String[] docenten = docentensep.split(","); // splitsen
        return docenten;
    }

    public static String[] getKlassen(){
        WebserviceHelper wsHelper = new WebserviceHelper();
        List<String> lijst = wsHelper.callWebservice(WebserviceHelper.GET_DOCENTEN);
        String klassensep = lijst.get(0);
        String klassen [] = klassensep.split(",");
        return klassen;
    }

    public static HashMap<String, String> getStudenten(String klas){
        HashMap<String, Object> properties = new HashMap<String, Object>();
        properties.put("klas", klas);
        WebserviceHelper wsHelper = new WebserviceHelper();
        List<String> lijst = wsHelper.callWebservice(WebserviceHelper.GET_STUDENTEN, properties);
        String studentensep = lijst.get(0);
        String[] studentensplit = studentensep.split(",");
        HashMap<String, String> studenten = new HashMap<String, String>();
        for (String student : studentensplit){
            String[] split = student.split(";");
            studenten.put(split[0], split[1]);
        }
        return studenten;
    }
}
